/**
 * Created by tdzl2003 on 6/28/16.
 */
import React, { PropTypes } from 'react';
import {
  View,
} from 'react-native';

import router from '../utils/routerDecorator';

import { loadToken } from '../logics/rpc';

@router('splash')
export default class Splash extends React.Component {
  static contextTypes = {
    navigator: PropTypes.object,
  };
  async componentWillMount() {
    try {
      if (await loadToken()) {
        // TODO: 向服务器发起请求,更新当前用户信息
        // await auth.refreshInfo();
        this.context.navigator.replace({ location: '/home' });
        return;
      }
    } catch (e) {
      // ignore e
    }
    this.context.navigator.replace({ location: '/login' });
  }
  render() {
    return (
      <View />
    );
  }
}
